package com.github.admin.edu.oauth.server.api.hystris;

import com.github.admin.edu.assembly.common.entity.JsonEntity;
import com.github.admin.edu.assembly.common.entity.JsonTree;
import com.github.admin.edu.assembly.common.util.JsonUtils;
import com.github.admin.edu.oauth.server.api.entity.TSysOrganization;
import com.github.admin.edu.oauth.server.api.service.ServiceOrganizationManagerServiceApi;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-1
 */
@Component
public class ServiceOrganizationManagerServiceHystris implements FallbackFactory<ServiceOrganizationManagerServiceApi> {
    @Override
    public ServiceOrganizationManagerServiceApi create(Throwable throwable) {
        return new ServiceOrganizationManagerServiceApi() {
            @Override
            public String getEntity(Integer id) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String saveOrUpdate(String jsonEntity) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String getAllByPager(String title, Integer current, Integer rows, String order, String fileId) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String getALLByPager(String jsonEntity) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String getAllEntity(String title, String order, String fileId) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String getAllEntityByTree() {
                return JsonUtils.toJson(new JsonTree<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String deleteAll(String ids) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String deleteByRootId(Integer id) {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }

            @Override
            public String findOrgByFirst() {
                return JsonUtils.toJson(new JsonEntity<TSysOrganization>("服务端异常，无法连接！"));
            }
        };
    }
}
